package edu.ccut.saturn.basecomponent.dataoperationcomponent;

import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameter;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;

public class SetDataValues extends DefaultComponent {
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		SaturnData saturnData =  (SaturnData)parameterContext.getParameterValue(0);
		List<IParameter> params = parameterContext.getParameters();
	    for(int i=1;i<(params.size()%2==1?params.size():params.size()-1);i++){
			Object key = parameterContext.getParameterValue(i);
			Object dataValue = parameterContext.getParameterValue(++i);
			
			if (key != null) {
				saturnData.set((String)key, dataValue);
			}
	    }
	    debug("after set value saturnData ===="+saturnData, parameterContext);
	}
}